<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <!--{include file='comm/header.tpl'}-->
    <title><!--{if $specInfo->specID !='' }-->修改规格<!--{else}-->添加规格<!--{/if}--></title>
</head>

<body>
<div style="width:100%">

    <div class="items clearfix">
        <h2 style="" class="tal">正在操作：<!--{if $specInfo->specID !='' }-->修改规格<!--{else}-->添加规格<!--{/if}--></h2>
        <div class="items2">
            <!--{if $error_msg}-->
	            <div class="error-box">
	                <!--{$error_msg}-->
	            </div>
            <!--{else}-->
            <div>
                <form id="spec_form" onsubmit="return false;">
                    <table>
                        <tbody>
                        <tr>
                            <td class="tar" width="150">规格名称：</td>
                            <td width="400">
                            	<input type="text" style="ime-mode:active;width:300px;" autocomplete="off"  name="specName" id="specName" maxlength="20" value="<!--{$specInfo->specName}-->">
                                <font color="red">*</font>
                                 <input type="hidden" name="specID" id="specID" value="<!--{$specInfo->specID}-->" />
                            </td>
                        </tr>
                        <tr>
                            <td class="tar" width="150">规格组：</td>
                            <td width="400">
								<select name="specGroupID" id="specGroupID" style="width:100px;">
									<option value="0">请选择</option>
	                            	<!--{foreach from=$specInfo->specGroup item=s_g}-->
	                            		<option value="<!--{$s_g->specGroupID}-->"><!--{$s_g->specGroupName}--></option>
	                            	<!--{/foreach}-->
                           		</select>
                            </td>
                        </tr>
                         <tr>
                            <td class="tar">排列序号：</td>
                            <td>
                            	<input type="text" style="ime-mode:active;width:80px;" autocomplete="off"  name="sortOrder" id="sortOrder" maxlength="6" value="<!--{$specInfo->sortOrder}-->">
                                <font color="red">*</font>
                            </td>
                        </tr>
                        <tr>
                            <td class="tar" >使用标志：</td>
                            <td>
                            	<!--{if $specInfo->useFlg ==1 }-->
	                            	<input type="radio" checked="checked" value="1" name="useFlg">启用 
	                            	<input type="radio" name="useFlg" value="0">禁用 
                            	<!--{else}-->
                            		<input type="radio"  value="1" name="useFlg">启用 
	                            	<input type="radio" checked="checked" name="useFlg" value="0">禁用 
                            	<!--{/if}-->
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>
            <!--{/if}-->

        </div>
    </div>

    <div class="bottom_fixbox">
        <div class="rectbox tac">
        	<input type="button" class="btn" onclick="spec.reset();" value="重置" />&nbsp;&nbsp;&nbsp;
        	<input type="button" class="btn" onclick="spec.check();" value="<!--{if $specInfo->specID !='' }-->修改规格<!--{else}-->添加规格<!--{/if}-->" />&nbsp;&nbsp;&nbsp;
            <input type="button" class="btn" onclick="E.closeWindows();" value="关闭" />
        </div>
    </div>



</div>

<script type="text/javascript">
    var spec = {
    	
        specID: <!--{$specInfo->specID|default:0}-->,
        //检查数据
        check: function() {
            this.dt = E.getFormValues("spec_form");
            var error_msg = "";
            if (this.dt.specGroupID == "0")
                error_msg += "请选择规格组<br />";
                
            if (this.dt.specName == "")
                error_msg += "规格名称不能为空<br />";
                
            if (!E.isInt(this.dt.sortOrder))
                error_msg += "排序序号必须为数字<br />";
                
            if (error_msg != "")
                E.alert(error_msg);
            else
            	spec.add() ;
        },

        //保存规格信息
        add: function() {
            $.ajax({
                type: "POST",
                url: "/invokingAjax-backend/goods/goodsSpec.ajax?operFlg=2" ,
                dataType: "JSON",
                data: this.dt,
                success: function( result_obj ) {
                    if (result_obj.code == 200) {
                        if(spec.specID == 0){
                        	E.opener("goodsSpec.load");
                        	E.alert(result_obj.message, 2);
                        	self.location = "/quanliadmin/app/goods/goodsSpec.pscript?operFlg=2" ;
                        }else{
                        	E.alert(result_obj.message, 2, "E.closeWindows");
                        	E.opener("goodsSpec.load");
                        }
                    } else {
                        E.alert(result_obj.message);
                    }
                }
            });
        },

        //清除商品信息
        reset: function() {
            $("#specName").val("");
            $("#description").val("");
            $("#show_img").html("");
            $("#spec_img").val("");
            $('input[name=useFlg]').get(0).checked = true;
        }

    };
    
	var specGroupID = "<!--{$specInfo->specGroupID}-->";
	if(specGroupID != "" )
		$("#specGroupID").val( specGroupID ) ;
	
</script>
</body>
</html>